/*
 * Copyright [2013-2021], Alibaba Group Holding Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.alibaba.polardbx.executor.operator.scan.impl;

import com.google.common.base.Preconditions;
import org.apache.hadoop.fs.Path;
import org.apache.orc.OrcProto;
import org.apache.orc.impl.OrcIndex;
import org.apache.orc.impl.OrcTail;

import java.util.Map;

public class PreheatFileMeta {
    private final Path filePath;
    private Map<Long, PreheatStripeMeta> preheatStripes;
    private OrcTail preheatTail;

    public PreheatFileMeta(Path filePath) {
        this.filePath = filePath;
    }

    public Path getFilePath() {
        return filePath;
    }

    public void setPreheatStripes(
        Map<Long, PreheatStripeMeta> preheatStripes) {
        this.preheatStripes = preheatStripes;
    }

    public OrcTail getPreheatTail() {
        return preheatTail;
    }

    public Map<Long, PreheatStripeMeta> getPreheatStripes() {
        return preheatStripes;
    }

    public void setPreheatTail(OrcTail preheatTail) {
        this.preheatTail = preheatTail;
    }

    public OrcIndex getOrcIndex(long stripeIndex) {
        PreheatStripeMeta stripeMeta = preheatStripes.get(stripeIndex);
        Preconditions.checkNotNull(stripeMeta);

        return stripeMeta.getOrcIndex();
    }

    public OrcProto.StripeFooter getStripeFooter(long stripeIndex) {
        PreheatStripeMeta stripeMeta = preheatStripes.get(stripeIndex);
        Preconditions.checkNotNull(stripeMeta);

        return stripeMeta.getStripeFooter();
    }
}
